Replace some assert_throws('Something', stuff) calls with assert_throws_dom. (#21392) This diff was generated by running: find . -type f -print0 | xargs -0 perl -pi -e "BEGIN { \$/ = undef; } s/assert_throws\(([ \n]*'[A-Za-z_]*') *(, *.)/assert_throws_dom(\1\2/gs" in bash (doesn't work in tcsh, due to the $ inside ""). This does affect indentation poorly in cases when the first arg was on the same line as the assert_throws, there was a newline after the ',' after the first arg, and the following args were lined up with the first arg. Fixing that, especially when there are multiple lines after the first arg, is not trivial with a regexp. Co-authored-by: Boris Zbarsky <bzbarsky@mit.edu> 
diff --git a/webrtc/RTCCertificate.html b/webrtc/RTCCertificate.html index a33ba9a..6b7626c 100644 --- a/webrtc/RTCCertificate.html +++ b/webrtc/RTCCertificate.html 
@@ -100,7 +100,7 @@  expires: 0  }).then(cert => {  assert_less_than_equal(cert.expires, Date.now()); - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  new RTCPeerConnection({ certificates: [cert] }));  });  }, 'Constructing RTCPeerConnection with expired certificate should reject with InvalidAccessError'); @@ -126,12 +126,12 @@  certificates: [cert1]  });   - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({  certificates: [cert2]  }));   - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({  certificates: [cert1, cert2]  })); 
diff --git a/webrtc/RTCConfiguration-bundlePolicy.html b/webrtc/RTCConfiguration-bundlePolicy.html index 83517db..e825d7b 100644 --- a/webrtc/RTCConfiguration-bundlePolicy.html +++ b/webrtc/RTCConfiguration-bundlePolicy.html 
@@ -107,7 +107,7 @@  const pc = new RTCPeerConnection({ bundlePolicy: 'max-bundle' });  assert_idl_attribute(pc, 'setConfiguration');   - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({ bundlePolicy: 'max-compat' }));  }, `setConfiguration({ bundlePolicy: 'max-compat' }) with initial bundlePolicy max-bundle should throw InvalidModificationError`);   @@ -116,7 +116,7 @@  assert_idl_attribute(pc, 'setConfiguration');    // the default value for bundlePolicy is balanced - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({}));  }, `setConfiguration({}) with initial bundlePolicy max-bundle should throw InvalidModificationError`);   
diff --git a/webrtc/RTCConfiguration-iceServers.html b/webrtc/RTCConfiguration-iceServers.html index 3f5c367..ee2b608 100644 --- a/webrtc/RTCConfiguration-iceServers.html +++ b/webrtc/RTCConfiguration-iceServers.html 
@@ -219,14 +219,14 @@  server.credential are omitted, then throw an InvalidAccessError.  */  config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turn:turn.example.net'  }] }));  }, 'with turn server and no credentials should throw InvalidAccessError');    config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turn:turn.example.net',  username: 'user' @@ -234,7 +234,7 @@  }, 'with turn server and only username should throw InvalidAccessError');    config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turn:turn.example.net',  credential: 'cred' @@ -242,14 +242,14 @@  }, 'with turn server and only credential should throw InvalidAccessError');    config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turns:turn.example.net'  }] }));  }, 'with turns server and no credentials should throw InvalidAccessError');    config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turns:turn.example.net',  username: 'user' @@ -257,7 +257,7 @@  }, 'with turns server and only username should throw InvalidAccessError');    config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turns:turn.example.net',  credential: 'cred' @@ -365,7 +365,7 @@  and abort these steps.  */  config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turns:turn.example.org',  credentialType: 'password', @@ -384,7 +384,7 @@  InvalidAccessError and abort these steps.  */  config_test(makePc => { - assert_throws('InvalidAccessError', () => + assert_throws_dom('InvalidAccessError', () =>  makePc({ iceServers: [{  urls: 'turns:turn.example.org',  credentialType: 'oauth', 
diff --git a/webrtc/RTCConfiguration-rtcpMuxPolicy.html b/webrtc/RTCConfiguration-rtcpMuxPolicy.html index 683b202..5198c90 100644 --- a/webrtc/RTCConfiguration-rtcpMuxPolicy.html +++ b/webrtc/RTCConfiguration-rtcpMuxPolicy.html 
@@ -89,7 +89,7 @@  test(() => {  const pc = new RTCPeerConnection({ rtcpMuxPolicy: 'require' });  assert_idl_attribute(pc, 'setConfiguration'); - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({ rtcpMuxPolicy: 'negotiate' }));    }, `setConfiguration({ rtcpMuxPolicy: 'negotiate' }) with initial rtcpMuxPolicy require should throw InvalidModificationError`); @@ -109,7 +109,7 @@  }    assert_idl_attribute(pc, 'setConfiguration'); - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({ rtcpMuxPolicy: 'require' }));    }, `setConfiguration({ rtcpMuxPolicy: 'require' }) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError`); @@ -130,7 +130,7 @@    assert_idl_attribute(pc, 'setConfiguration');  // default value for rtcpMuxPolicy is require - assert_throws('InvalidModificationError', () => + assert_throws_dom('InvalidModificationError', () =>  pc.setConfiguration({}));    }, `setConfiguration({}) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError`); 
diff --git a/webrtc/RTCDTMFSender-insertDTMF.https.html b/webrtc/RTCDTMFSender-insertDTMF.https.html index 62a5f04..be6e3c6 100644 --- a/webrtc/RTCDTMFSender-insertDTMF.https.html +++ b/webrtc/RTCDTMFSender-insertDTMF.https.html 
@@ -75,15 +75,15 @@  promise_test(t => {  return createDtmfSender()  .then(dtmfSender => { - assert_throws('InvalidCharacterError', () => + assert_throws_dom('InvalidCharacterError', () =>  // 'F' is invalid  dtmfSender.insertDTMF('123FFABC'));   - assert_throws('InvalidCharacterError', () => + assert_throws_dom('InvalidCharacterError', () =>  // 'E' is invalid  dtmfSender.insertDTMF('E'));   - assert_throws('InvalidCharacterError', () => + assert_throws_dom('InvalidCharacterError', () =>  // ' ' is invalid  dtmfSender.insertDTMF('# *'));  }); @@ -99,7 +99,7 @@  const dtmfSender = transceiver.sender.dtmf;    transceiver.stop(); - assert_throws('InvalidStateError', () => dtmfSender.insertDTMF('')); + assert_throws_dom('InvalidStateError', () => dtmfSender.insertDTMF(''));    }, 'insertDTMF() should throw InvalidStateError if transceiver is stopped');   @@ -127,7 +127,7 @@  await callee.setLocalDescription(answer);  await caller.setRemoteDescription(answer);  assert_equals(transceiver.currentDirection, 'recvonly'); - assert_throws('InvalidStateError', () => dtmfSender.insertDTMF('')); + assert_throws_dom('InvalidStateError', () => dtmfSender.insertDTMF(''));  }, 'insertDTMF() should throw InvalidStateError if transceiver.currentDirection is recvonly');    promise_test(async t => { @@ -142,7 +142,7 @@  const answer = await generateAnswer(offer);  await pc.setRemoteDescription(answer);  assert_equals(transceiver.currentDirection, 'inactive'); - assert_throws('InvalidStateError', () => dtmfSender.insertDTMF('')); + assert_throws_dom('InvalidStateError', () => dtmfSender.insertDTMF(''));  }, 'insertDTMF() should throw InvalidStateError if transceiver.currentDirection is inactive');    /* @@ -180,7 +180,7 @@  dtmfSender = sender.dtmf;  pc.removeTrack(sender);  pc.close(); - assert_throws('InvalidStateError', () => + assert_throws_dom('InvalidStateError', () =>  dtmfSender.insertDTMF('123'));  });  }, 'insertDTMF() after remove and close should reject'); 
diff --git a/webrtc/RTCDataChannel-id.html b/webrtc/RTCDataChannel-id.html index 0cf0197..355f6a3 100644 --- a/webrtc/RTCDataChannel-id.html +++ b/webrtc/RTCDataChannel-id.html 
@@ -331,9 +331,9 @@    // Try creating one further channel on both sides. The attempt should fail since all IDs are  // taken. If one ID is available, the implementation probably miscounts (or I did in the test). - assert_throws('OperationError', () => + assert_throws_dom('OperationError', () =>  pc1.createDataChannel('this is too exhausting!')); - assert_throws('OperationError', () => + assert_throws_dom('OperationError', () =>  pc2.createDataChannel('this is too exhausting!'));    maybeDone(); 
diff --git a/webrtc/RTCDataChannel-send.html b/webrtc/RTCDataChannel-send.html index 4565a83..406937f 100644 --- a/webrtc/RTCDataChannel-send.html +++ b/webrtc/RTCDataChannel-send.html 
@@ -54,7 +54,7 @@  const pc = new RTCPeerConnection();  const channel = pc.createDataChannel('test');  assert_equals(channel.readyState, 'connecting'); - assert_throws('InvalidStateError', () => channel.send(helloString)); + assert_throws_dom('InvalidStateError', () => channel.send(helloString));  }, 'Calling send() when data channel is in connecting state should throw InvalidStateError');    /* @@ -313,6 +313,6 @@  // "send" method step 4:  // If the byte size of "data" exceeds the value of maxMessageSize, throw  // a TypeError. - assert_throws('TypeError', () => channel1.send(message)); + assert_throws_dom('TypeError', () => channel1.send(message));  }, 'Calling send() up to max size should succeed, above max size should fail');  </script> 
diff --git a/webrtc/RTCIceTransport-extension.https.html b/webrtc/RTCIceTransport-extension.https.html index 13f2173..40e9f30 100644 --- a/webrtc/RTCIceTransport-extension.https.html +++ b/webrtc/RTCIceTransport-extension.https.html 
@@ -68,7 +68,7 @@  test(t => {  const iceTransport = makeIceTransport(t);  iceTransport.stop(); - assert_throws('InvalidStateError', () => iceTransport.gather({})); + assert_throws_dom('InvalidStateError', () => iceTransport.gather({}));  }, 'gather() throws if closed');    test(t => { @@ -80,7 +80,7 @@  test(t => {  const iceTransport = makeIceTransport(t);  iceTransport.gather({}); - assert_throws('InvalidStateError', () => iceTransport.gather({})); + assert_throws_dom('InvalidStateError', () => iceTransport.gather({}));  }, 'gather() throws if called twice');    promise_test(async t => { @@ -133,7 +133,7 @@  test(() => {  const iceTransport = new RTCIceTransport();  iceTransport.stop(); - assert_throws('InvalidStateError', + assert_throws_dom('InvalidStateError',  () => iceTransport.start(dummyRemoteParameters));  assert_equals(iceTransport.getRemoteParameters(), null);  }, `start() throws if closed`); @@ -183,14 +183,14 @@  test(() => {  const iceTransport = new RTCIceTransport();  iceTransport.stop(); - assert_throws('InvalidStateError', + assert_throws_dom('InvalidStateError',  () => iceTransport.addRemoteCandidate(candidate1));  assert_array_equals(iceTransport.getRemoteCandidates(), []);  }, 'addRemoteCandidate() throws if closed');    test(() => {  const iceTransport = new RTCIceTransport(); - assert_throws('OperationError', + assert_throws_dom('OperationError',  () => iceTransport.addRemoteCandidate(  new RTCIceCandidate({ candidate: 'invalid', sdpMid: '' })));  assert_array_equals(iceTransport.getRemoteCandidates(), []); @@ -217,7 +217,7 @@  test(t => {  const iceTransport = makeIceTransport(t);  iceTransport.start(dummyRemoteParameters); - assert_throws('InvalidStateError', + assert_throws_dom('InvalidStateError',  () => iceTransport.start(dummyRemoteParameters, 'controlling'));  }, 'start() throws if later called with a different role');   
diff --git a/webrtc/RTCPeerConnection-addTrack.https.html b/webrtc/RTCPeerConnection-addTrack.https.html index 3f4f927..7585961 100644 --- a/webrtc/RTCPeerConnection-addTrack.https.html +++ b/webrtc/RTCPeerConnection-addTrack.https.html 
@@ -46,7 +46,7 @@  const [track] = stream.getTracks();    pc.close(); - assert_throws('InvalidStateError', () => pc.addTrack(track, stream)) + assert_throws_dom('InvalidStateError', () => pc.addTrack(track, stream))  }, 'addTrack when pc is closed should throw InvalidStateError');    /* @@ -142,7 +142,7 @@  const [track] = stream.getTracks();    pc.addTrack(track, stream); - assert_throws('InvalidAccessError', () => pc.addTrack(track, stream)); + assert_throws_dom('InvalidAccessError', () => pc.addTrack(track, stream));  }, 'Adding the same track multiple times should throw InvalidAccessError');    /* 
diff --git a/webrtc/RTCPeerConnection-createDataChannel.html b/webrtc/RTCPeerConnection-createDataChannel.html index 350f715..67b40c9 100644 --- a/webrtc/RTCPeerConnection-createDataChannel.html +++ b/webrtc/RTCPeerConnection-createDataChannel.html 
@@ -69,7 +69,7 @@  const pc = new RTCPeerConnection();  pc.close();  assert_equals(pc.signalingState, 'closed', 'signaling state'); - assert_throws('InvalidStateError', () => pc.createDataChannel('')); + assert_throws_dom('InvalidStateError', () => pc.createDataChannel(''));  }, 'createDataChannel with closed connection should throw InvalidStateError');    /* @@ -597,7 +597,7 @@  assert_equals(dc2.id, 43,  'Expect dc2.id to be 43');   - assert_throws('OperationError', () => + assert_throws_dom('OperationError', () =>  pc.createDataChannel('channel-3', {  negotiated: true,  id: 42, @@ -634,7 +634,7 @@    assert_equals(dc2.id, 43, 'Expect dc2.id to be 43');   - assert_throws('OperationError', () => + assert_throws_dom('OperationError', () =>  pc1.createDataChannel('channel-3', {  negotiated: true,  id: 42, @@ -658,7 +658,7 @@  assert_not_equals(dc1.id, null,  'Expect dc1.id to be assigned after remote description has been set');   - assert_throws('OperationError', () => + assert_throws_dom('OperationError', () =>  pc1.createDataChannel('channel-2', {  negotiated: true,  id: dc1.id, 
diff --git a/webrtc/RTCPeerConnection-removeTrack.https.html b/webrtc/RTCPeerConnection-removeTrack.https.html index 10b4cfb..9e61ef7 100644 --- a/webrtc/RTCPeerConnection-removeTrack.https.html +++ b/webrtc/RTCPeerConnection-removeTrack.https.html 
@@ -43,7 +43,7 @@  const { sender } = transceiver;    pc.close(); - assert_throws('InvalidStateError', () => pc.removeTrack(sender)); + assert_throws_dom('InvalidStateError', () => pc.removeTrack(sender));  }, 'addTransceiver - Calling removeTrack when connection is closed should throw InvalidStateError');    promise_test(async t => { @@ -56,7 +56,7 @@  const sender = pc.addTrack(track, stream);    pc.close(); - assert_throws('InvalidStateError', () => pc.removeTrack(sender)); + assert_throws_dom('InvalidStateError', () => pc.removeTrack(sender));  }, 'addTrack - Calling removeTrack when connection is closed should throw InvalidStateError');    promise_test(async t => { @@ -70,7 +70,7 @@    const pc2 = new RTCPeerConnection();  pc2.close(); - assert_throws('InvalidStateError', () => pc2.removeTrack(sender)); + assert_throws_dom('InvalidStateError', () => pc2.removeTrack(sender));  }, 'addTransceiver - Calling removeTrack on different connection that is closed should throw InvalidStateError');    promise_test(async t => { @@ -84,7 +84,7 @@    const pc2 = new RTCPeerConnection();  pc2.close(); - assert_throws('InvalidStateError', () => pc2.removeTrack(sender)); + assert_throws_dom('InvalidStateError', () => pc2.removeTrack(sender));  }, 'addTrack - Calling removeTrack on different connection that is closed should throw InvalidStateError');    /* @@ -102,7 +102,7 @@    const pc2 = new RTCPeerConnection();  t.add_cleanup(() => pc2.close()); - assert_throws('InvalidAccessError', () => pc2.removeTrack(sender)); + assert_throws_dom('InvalidAccessError', () => pc2.removeTrack(sender));  }, 'addTransceiver - Calling removeTrack on different connection should throw InvalidAccessError');    promise_test(async t => { @@ -116,7 +116,7 @@    const pc2 = new RTCPeerConnection();  t.add_cleanup(() => pc2.close()); - assert_throws('InvalidAccessError', () => pc2.removeTrack(sender)); + assert_throws_dom('InvalidAccessError', () => pc2.removeTrack(sender));  }, 'addTrack - Calling removeTrack on different connection should throw InvalidAccessError')    /* 
diff --git a/webrtc/RTCPeerConnection-setRemoteDescription.html b/webrtc/RTCPeerConnection-setRemoteDescription.html index efa79d4..3f335d7 100644 --- a/webrtc/RTCPeerConnection-setRemoteDescription.html +++ b/webrtc/RTCPeerConnection-setRemoteDescription.html 
@@ -67,7 +67,7 @@  await pc.setRemoteDescription({ type: 'answer', sdp: 'invalid' });  t.unreached_func("Should have rejected.");  } catch (e) { - assert_throws('InvalidStateError', () => { throw e }); + assert_throws_dom('InvalidStateError', () => { throw e });  }  }, 'setRemoteDescription() with invalid SDP and stable state should reject with InvalidStateError');   
diff --git a/webrtc/RTCRtpSender-setStreams.https.html b/webrtc/RTCRtpSender-setStreams.https.html index 08592da..45b47d0 100644 --- a/webrtc/RTCRtpSender-setStreams.https.html +++ b/webrtc/RTCRtpSender-setStreams.https.html 
@@ -123,6 +123,6 @@  const transceiver = pc.addTransceiver('audio');    pc.close(); - assert_throws('InvalidStateError', () => transceiver.sender.setStreams(stream1, stream2)); + assert_throws_dom('InvalidStateError', () => transceiver.sender.setStreams(stream1, stream2));  }, 'setStreams() fires InvalidStateError on a closed peer connection.');  </script> 
diff --git a/webrtc/RTCRtpTransceiver-setCodecPreferences.html b/webrtc/RTCRtpTransceiver-setCodecPreferences.html index c553c9d..dff1eb2 100644 --- a/webrtc/RTCRtpTransceiver-setCodecPreferences.html +++ b/webrtc/RTCRtpTransceiver-setCodecPreferences.html 
@@ -81,7 +81,7 @@  const pc = new RTCPeerConnection();  const transceiver = pc.addTransceiver('audio');  const capabilities = RTCRtpSender.getCapabilities('video'); - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(capabilities.codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(capabilities.codecs));    }, `setCodecPreferences() on audio transceiver with codecs returned from getCapabilities('video') should throw InvalidModificationError`);   @@ -95,7 +95,7 @@  sdpFmtpLine: '0-15'  }];   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with user defined codec with invalid mimeType should throw InvalidModificationError`);   @@ -109,7 +109,7 @@  sdpFmtpLine: '0-15'  }];   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with user defined codec should throw InvalidModificationError`);   @@ -126,7 +126,7 @@  sdpFmtpLine: '0-15'  }];   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with user defined codec together with codecs returned from getCapabilities() should throw InvalidModificationError`);   @@ -137,7 +137,7 @@  const codecs = [capabilities.codecs[0]];  codecs[0].clockRate = codecs[0].clockRate / 2;   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with modified codec clock rate should throw InvalidModificationError`);   @@ -148,7 +148,7 @@  const codecs = [capabilities.codecs[0]];  codecs[0].channels = codecs[0].channels + 11;   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with modified codec channel count should throw InvalidModificationError`);   @@ -159,7 +159,7 @@  const codecs = [capabilities.codecs[0]];  codecs[0].sdpFmtpLine = "modifiedparameter=1";   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with modified codec parameters should throw InvalidModificationError`);   @@ -176,7 +176,7 @@  const { channels=2 } = codec;  codec.channels = channels+1;   - assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs)); + assert_throws_dom('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));    }, `setCodecPreferences() with modified codecs returned from getCapabilities() should throw InvalidModificationError`);